package com.ideal.manage.esms.controller.report;

import com.alibaba.fastjson.JSONObject;
import com.ideal.manage.esms.bean.DTO.PageDto;
import com.ideal.manage.esms.service.report.ReportYearService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.util.List;
import java.util.Map;

/**
 * @author Allen
 * <p>
 * 年报信息处理入口
 */
@Controller
@RequestMapping("report")
public class ReportYearController {
    @Autowired
    private ReportYearService reportYearService;

    /**
     * 电量统计数据
     *
     * @return
     */
    @RequestMapping("chart_batteryLeft")
    @ResponseBody
    public Map<String, JSONObject> batteryLeft(String id) {
        //定义时间,本年第一天到最后一天
        try {
            return reportYearService.getBatteryLeftData(id);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 故障信息
     * (饼图)
     *
     * @return
     */
    @RequestMapping("chart_faultInformation")
    @ResponseBody
    public List<JSONObject> faultInformation(String id) {
        //定义时间,本年第一天到最后一天

        return reportYearService.getFaultInformation(id);
    }


    /**
     * 故障信息 Table
     *
     * @return
     */
    @RequestMapping("report_fault_information")
    @ResponseBody
    public PageDto getFaultInformationDataTable(int pageNum, HttpServletRequest request) {

        return reportYearService.getFaultInformationDataTable(pageNum, request);
    }


    /**
     * 诊断信息统计(电池组容量诊断结果 )
     *
     * @return
     */
    @RequestMapping("chart_Ones")
    @ResponseBody
    public Map<String, JSONObject> dignosticOne(String id) {
        //定义时间,本年第一天到最后一天
        try {
            return reportYearService.getdignosticOne(id);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 诊断信息统计(电池组DCIR诊断结果 )
     *
     * @return
     */
    @RequestMapping("chart_Twos")
    @ResponseBody
    public Map<String, JSONObject> dignosticTwo(String id) {
        //定义时间,本年第一天到最后一天
        try {
            return reportYearService.getdignosticTwo(id);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 诊断信息统计(电池组循环次数 )
     *
     * @return
     */
    @RequestMapping("chart_Thress")
    @ResponseBody
    public Map<String, JSONObject> dignosticThress() {
        //定义时间,本年第一天到最后一天
        try {
            return reportYearService.getdignosticThress();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
    /*................................end.................................*/

    /**
     * 电池包不一致入库
     *
     * @return
     */
    @RequestMapping("package_data")
    @ResponseBody
    public String getPackageInconformityData(String id) {
        try {
            return reportYearService.getPackageInconformityData(id);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 收益表及环保贡献 入库
     *
     * @param id
     * @return
     */
    @RequestMapping("tearnings_data")
    @ResponseBody
    public String getTearningsData(String id) {
        return reportYearService.getTearningsData(id);

    }

    /**
     * 故障信息 Table
     *
     * @return
     */
    @RequestMapping("report_package")
    @ResponseBody
    public PageDto getPackageInconformity(int pageNum, HttpServletRequest request) {

        return reportYearService.getPackageInconformity(pageNum, request);
    }

}
